/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __DROPDOWN_H__
#define __DROPDOWN_H__

#pragma once

#include "List.h"

namespace gui{

/**
 * \ingroup coreGUI
 *
 * The GUI Dropdown class.<br>
 * A Dropdown is a small list, where just one (the selected) element is shown.<br>
 * The other possible elements will be displayed upon mouse click.
 *
 * \date 03-28-2007
 *
 * \author juckel
 * \author dennis
 * 
 * \todo Buttons below the list will be clicked
 *
 */
class GUI_EXPORT DropDown :
	public Component, 
	protected IMouseListener, 
	public IChangeListener,
	public IChangeObserver
{
public:
	DropDown(void);
	~DropDown(void);

	/// Sets the title of the element in case no Item is selected.
	void setTitle(const std::string &str);

	/// Adds a string to the dropdown element
	void addString(const std::string &str);

	/// Removes a string from the dropdown element
	void removeString(const std::string &str);

	/// Sets the dimension of the dropdown. The h value will be ignored.
	void setDimension(int x, int y, int w, int h);

	/// Set number of Entries that are shown at a time. For others use scroll buttons.
	void setNumberOfVisibleEntries(int val);

	/// Set number of elements you scroll
	void setScrollSteps(int val);

	/// Draws the element
	virtual void draw();

	virtual void clear();

	std::string getSelectedItem() const;

	int getSelectedIndex() const;
	void setSelectedIndex(int id);

	const unsigned int getNumItems() const;

	void setFont(IFont* font);

	virtual void onChangeEvent(const ChangeEvent &ce);

	/// Returns the GUI type
	virtual inline const int getGUIType() const { return GUI_DROPDOWN; }

protected:
	// Event handlers from the list
	virtual void onMouseReleaseEvent(const MouseEvent &mevent);
	virtual void onMouseLeaveEvent(const MouseEvent &mevent);

	// Own event handlers
	virtual void onMouseLeft(const MouseEvent &me);
	virtual void onMousePressed(const MouseEvent &me);

	List *m_pList;
	std::string m_sTitle;
};

}
#endif // __DROPDOWN_H__
